package com.apps.sevents;

import com.apps.sworld.sWorld;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@Order(1)
@Slf4j
@Component
public class Load implements CommandLineRunner {

    @Autowired(required = false)
    private List<sWorld>  sWorlds;


    @Override
    public void run(String... args) throws Exception
    {

        log.info("应用开始启动");
        for(sWorld service:sWorlds)
        {
            service.onInit();
        }

        log.info("执行自定义启动事件");
        for(sWorld service:sWorlds)
        {
            service.onLoad();
        }
        log.info("应用启动完毕");
    }
}
